package org.nowcoder.leetcode.bit;

/**
 * Title  : 371. Sum of Two Integers
 * Source : https://leetcode.cn/problems/sum-of-two-integers
 * Author : XrazYang
 * Date   : 2023-10-17
 */

public class LeetCode_371 {
    //位运算四则运算
    public int getSum(int a, int b) {
        while (b != 0) {
            int temp = a;
            a = temp ^ b;           // a ^ b
            b = (temp & b) << 1;  // (a & b) << 1
        }
        return a;
    }
}
